<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


	<xsl:include href="main.xsl"/>

	<!--
	additional scripts
	-->
	<xsl:template mode="script" match="/">
		<script type="text/javascript" language="JavaScript">
			function update1()
			{
				if (document.elementUpdateForm.name.value.length &lt; 1)
				{
					alert('A category name must be filled in.');
					return;
				}
				document.elementUpdateForm.submit()
			}
			function deleteBranch(url)
			{
				if(confirm("Delete the selected element ?"))
					sendUrl(url);
			}
			
		</script>
	</xsl:template>
	
	<!--
	page content
	-->
	<xsl:template name="content">
		<xsl:call-template name="formLayout">
			<xsl:with-param name="title">
				<xsl:choose>
					<xsl:when test="/root/response/record/id">
						<xsl:value-of select="/root/gui/strings/updateElement"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="/root/gui/strings/newElement"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:with-param>
			 <xsl:with-param name="menu">contentAdmin</xsl:with-param>
			<xsl:with-param name="content">
				<xsl:call-template name="form"/>
                                <!--
				<button class="content" onclick="goBack()"><xsl:value-of select="/root/gui/strings/back"/></button>
                                -->
				&#160;
				<button class="content" onclick="update1()"><xsl:value-of select="/root/gui/strings/save"/></button>
		
				<xsl:call-template name="branches-list"/>
			</xsl:with-param>
					</xsl:call-template>
	</xsl:template>
	
	<!--
	form
	-->
	<xsl:template name="form">
		<div class="important"><xsl:value-of select="/root/gui/strings/localizationHelp"/></div>
		<form name="elementUpdateForm" accept-charset="UTF-8" action="{/root/gui/locService}/organization.update" method="post">
			<input type="submit" style="display: none;" />
			<xsl:if test="/root/response/record/id">
				<input type="hidden" name="id" value="{/root/response/record/id}"/>
			</xsl:if>
			<table>
				<tr>
					<th class="padded"><xsl:value-of select="/root/gui/strings/name"/></th>
					<td class="padded"><input class="content" type="text" name="name" value="{/root/response/record/name}" size="60"/></td>
				</tr>
			</table>
		</form>
	</xsl:template>
	
	
	<xsl:template name="branches-list">
				<table width="70%" border="0" cellpadding="4">
				<tr>
					<th class="padded, bottom_border"><xsl:value-of select="/root/gui/strings/name"/></th>
					<th class="padded"><xsl:value-of select="/root/gui/strings/operation"/></th>
				</tr>
				<xsl:for-each select="/root/response/branches/response/record">
					<tr>
						<td class="padded, bottom_border"><xsl:value-of select="name"/></td>
						<td class="padded" width="150px">
							<button class="content" onclick="load('{/root/gui/locService}/branch.get?id={id}&amp;parentId={id_organization}')"><xsl:value-of select="/root/gui/strings/edit"/></button>
							&#160;
							<button class="content" onclick="deleteBranch('{/root/gui/locService}/branch.remove?id={id}')"><xsl:value-of select="/root/gui/strings/delete"/></button>
						</td>
					</tr>
				</xsl:for-each>
			</table>
				<button class="content" onclick="load('{/root/gui/locService}/branch.get?parentId=' + document.getElementById('id').value )"><xsl:value-of select="/root/gui/strings/newElement"/></button>
			</xsl:template>
</xsl:stylesheet>
